﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using TireService.Data;
using System.IO;

namespace TireService.Business.Portal.Popup
{
    public partial class Invoice : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            int InvoiceId = Convert.ToInt32(Request.QueryString["InvoiceId"]);

            EconomicInterface ecoInterface = new EconomicInterface();

            Context.Response.Buffer = false;
            //Stream file = ecoInterface.GetInvoiceStream(InvoiceId, CustomerId);
            Stream file = ecoInterface.GetInvoiceStream(InvoiceId);
            byte[] mybuff = new byte[1024];
            long count;

            while ((count = file.Read(mybuff, 0, mybuff.Length)) > 0)
            {
                if (Context.Response.IsClientConnected)
                {
                    Context.Response.OutputStream.Write(mybuff, 0, mybuff.Length);
                    Context.Response.Flush();
                }
            }
        }
    }
}